<?php

$view = '
<?php if (isset($records) && is_array($records) && count($records)) : ?>
				
<form method="post" action="<?php echo base_url().\''.$module_name_lower.'/bulk\' ?>" onSubmit="return confirm(\'<?php echo lang(\''.$module_name_lower.'_bulk_confirm\') ?>\')" class="table-form">
	
<div class="row table-top-container">
	<div class="span6 left-container">		
		<label for="action"><?php echo lang(\''.$module_name_lower.'_with_selected\') ?>:</label> 
		<div class="input">
			<select name="action">
				<option value="delete"><?php echo lang(\''.$module_name_lower.'_delete\') ?></option>
			</select> 
			&nbsp;&nbsp;
			<input type="submit" class="btn" name="apply" value="<?php echo lang(\''.$module_name_lower.'_apply\') ?>">
		</div>
	</div>
	<div class="span6 right-container">
		<a class="btn success" href="<?php echo site_url(\''.$module_name_lower.'/create\')?>"><?php echo lang(\''.$module_name_lower.'_create_new_button\');?></a>
	</div>
</div>
	
	<table class="bordered-table zebra-striped">
		<thead>
			<tr>
			<th style="width: 2em"><input class="check-all" type="checkbox"></th>';

for($counter=1; $field_total >= $counter; $counter++)
{
	// only build on fields that have data entered. 

	//Due to the requiredif rule if the first field is set the the others must be

	if (set_value("view_field_label$counter") == NULL)
	{
		continue; 	// move onto next iteration of the loop
	}
	$view .= '
		<th>'. set_value("view_field_label$counter").'</th>';
}
if ($use_soft_deletes == 'true')
{
	$view .= '
		<th>Deleted</th>';
}
if ($use_created == 'true')
{
	$view .= '
		<th>Created</th>';
}
if ($use_modified == 'true')
{
	$view .= '
		<th>Modified</th>';
}

$view .= '
		<th><?php echo lang(\''.$module_name_lower.'_actions\'); ?></th>
		</tr>
		</thead>
		<tbody>
<?php
foreach ($records as $record) : ?>
			<tr>';
			
$view .= '
				<td class="column-check"><input type="checkbox" value="<?php echo $record->id?>" name="checked[]">
';
for($counter=1; $field_total >= $counter; $counter++)
{
	// only build on fields that have data entered. 

	//Due to the requiredif rule if the first field is set the the others must be

	if (set_value("view_field_name$counter") == NULL || set_value("view_field_name$counter") == $primary_key_field)
	{
		continue; 	// move onto next iteration of the loop
	}
	$view .= '
				<td><?php echo $record->'.$module_name_lower.'_'.set_value("view_field_name$counter").'?></td>';
}
if ($use_soft_deletes == 'true')
{
	$view .= '
				<td><?php echo $record->deleted > 0 ? lang(\''.$module_name_lower.'_true\') : lang(\''.$module_name_lower.'_false\')?></td>';
}
if ($use_created == 'true')
{
	$view .= '
				<td><?php echo $record->'.set_value("created_field").'?></td>';
}
if ($use_modified == 'true')
{
	$view .= '
				<td><?php echo $record->'.set_value("modified_field").'?></td>';
}
$view .= '
				<td><?php echo anchor(\''.$module_name_lower.'/edit/\'. $record->'.$primary_key_field.', lang(\''.$module_name_lower.'_edit\'), \'class=""\'); ?></td>
			</tr>
<?php endforeach; ?>
		</tbody>
	</table>
	</form>
	<div class="row table-bottom-container">
		<div class="span6 left-container"><?php echo $this->pagination->create_links(); ?>&nbsp;</div>
		<div class="span6 right-container"><p><?php echo lang(\''.$module_name_lower.'_total_rows\'); ?>: <?php echo $total_rows; ?></p></div>
	</div>
	
	<?php else : ?>
		<div class="alert-message block-message warning">
			<p><?php echo lang(\''.$module_name_lower.'_no_records\'); ?></p>
			<p><a class="btn success" href="<?php echo site_url(\''.$module_name_lower.'/create\')?>"><?php echo lang(\''.$module_name_lower.'_create_new_button\');?></a></p>
		</div>
		
	<?php endif; ?>
				
		
';

	echo $view;
?>